package net.sx.minemodule.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import net.sx.minemodule.R;
import net.sx.minemodule.mvp.bean.WithDrawInfoListBean;

import java.util.List;

public class MineWithDrawInfoListAdapter extends RecyclerView.Adapter<MineWithDrawInfoListAdapter.WithDrawInfoViewHolder> {

    private Context context;
    private LayoutInflater inflater;
    private List<WithDrawInfoListBean> dataList;

    public MineWithDrawInfoListAdapter(Context context, List<WithDrawInfoListBean> beanList) {
        this.context = context;
        inflater = LayoutInflater.from(context);
        dataList = beanList;
    }

    @NonNull
    @Override
    public WithDrawInfoViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        return new WithDrawInfoViewHolder(inflater.inflate(R.layout.mine_item_with_draw_info_one, viewGroup, false));
    }

    @Override
    public void onBindViewHolder(@NonNull WithDrawInfoViewHolder withDrawInfoViewHolder, int i) {
        WithDrawInfoListBean bean = dataList.get(i);
        if (bean != null) {
            withDrawInfoViewHolder.tvDate.setText(bean.getAffirmtime());
            withDrawInfoViewHolder.tvContent.setText(bean.getTitle());
        }
    }

    @Override
    public int getItemCount() {
        return dataList.size();
    }

    static class WithDrawInfoViewHolder extends RecyclerView.ViewHolder {

        TextView tvDate;
        TextView tvContent;

        public WithDrawInfoViewHolder(@NonNull View itemView) {
            super(itemView);
            tvDate = itemView.findViewById(R.id.tv_date_with_draw_info_list);
            tvContent = itemView.findViewById(R.id.tv_content_with_draw_info_list);
        }
    }

}
